﻿@{
    Layout = "_LayoutalertForm";
    ViewData["title"] = "系统用户密码修改";
}
@section headers{
}
<form id="form1">
    <div style="padding-top: 20px; margin-right: 30px;">
        <table class="form">
            <tr>
                <th class="formTitle">用户名</th>
                <td class="formValue">
                    @(string.IsNullOrWhiteSpace(ViewBag.RealName) ? "" : ViewBag.RealName)
                </td>
                <td style=" width:50px"></td>
            </tr>
            <tr>
                <th class="formTitle">原密码</th>
                <td class="formValue">
                    <input id="Password" name="Password" type="password" class="form-control" placeholder="请输入原密码" />
                </td>
                <td></td>
            </tr>
            <tr>
                <th class="formTitle">新密码</th>
                <td class="formValue">
                    <input id="NewPassword" name="NewPassword" type="password" class="form-control" placeholder="请输入新密码" />
                </td>
                <td></td>
            </tr>
            <tr>
                <th class="formTitle">确认密码</th>
                <td class="formValue">
                    <input id="ConfirmPassword" name="ConfirmPassword" type="password" class="form-control" placeholder="请输入确认密码" />
                </td>
                <td></td>
            </tr>
            <tr>
                <th class="formTitle"></th>
                <td class="formValue">
                    <button class="btn btn-info" type="button" id="btnSave">
                        <i class="ace-icon fa fa-check bigger-110"></i>
                        确定
                    </button>
                    &nbsp;
                    &nbsp;
                    &nbsp;
                    &nbsp;
                    <a href="javascript:void(0);" id="add_cacel" class="btn"><i class="ace-icon fa fa-arrow-left icon-on-left bigger-110"></i>取消</a>
                </td>
                <td></td>
            </tr>
        </table>
    </div>
</form>

@section scripts{
    <script type="text/javascript">
        $("#add_cacel").on("click", function () {
            var index = parent.layer.getFrameIndex(window.name);
            parent.layer.close(index);
        });
        $("#btnSave").on("click", function () {
            var $form = $("#form1");
            if ($form.valid()) {
                $.ajax({
                    url: "/SysUser/ChangePassword",
                    data: $form.serialize(),
                    type: "POST",
                    cache: false,
                    async: false,
                    success: function (r) {
                        if (r.code == 0) {
                            var index = parent.layer.getFrameIndex(window.name);
                            parent.layer.close(index);
                        }
                        else {
                            $.MsgBox.Alert(r.msg);
                        }
                    },
                    error: function () {
                        $.MsgBox.Alert("保存失败");
                    }
                });
            }
        })
    </script>
}